 public class Test{
     public static void main(String[] args) {
         String str2 = new String("abcd");
         System.out.println(str2);
     }
     public static void main16(String[] args) {
         String str1 = "abcd";
         String str2 = new String("abcd");
         String str3 = "abcd";
         System.out.println(str1 == str2);
         System.out.println(str1 == str3);
     }
     public static void main15(String[] args) {
         String str = "   hello  abcd    ";
         System.out.println(str);
         String ret = str.trim();
         System.out.println(ret);
         String str2 = new String("hello");
     }

     public static void main14(String[] args) {
        String str = "abcdefgh";
        String s = str .substring(0,6);
         System.out.println(s);
     }
     public static void main13(String[] args) {
         String str = "name=zhangsan&age=18";
         String[] strs = str.split("&");
         for (int i = 0; i < strs.length; i++) {
            String[] string = strs[i].split("=");
            for (String s:string){
                System.out.println(s);
            }
         }
     }
     public static void main12(String[] args) {
         String str = "192&168@1=1";
         String[] strs = str.split("&|@|=");
         for (int i = 0; i < strs.length; i++) {
             System.out.println(strs[i]);
         }
     }
     public static void main11(String[] args) {
         String str1 = "aaaaabbbbbddddcccc";
         String ret1 = str1.replace('a','p');
        // System.out.println(ret1);
         String str2 = "abaababababcd";
         String ret2 = str2.replaceAll("ab","ooo");
         //System.out.println(ret2);
         String ret3 = str1.replaceFirst("ab"," # ");
         System.out.println(ret3);
     }
     public static void main10(String[] args) {
         String s = String.format("%d-%d-%d",2022,12,25);
         System.out.println(s);
     }
     public static void main9(String[] args) {
         String str1 = "abcdef";
         char[] array = str1.toCharArray();
         for (int i = 0; i < array.length; i++) {
             System.out.println(array[i]);
         }
         String s2 = new String(array);
         System.out.println(s2);
     }
     public static void main8(String[] args) {
         //String str1 = "abcd";
         String str2 = "ABCD";
         System.out.println(str2.toLowerCase());
     }
     public static void main7(String[] args) {
        // String str1 = String.valueOf(123);
        // System.out.println(str1);
         String str2 = "12345";
         int data = Integer.parseInt(str2);
         System.out.println(data);
     }
    public static void main6(String[] args) {
        String str1 = "abcabcabcabcde";
       // System.out.println(str1.indexOf('c',6));
        //在主串中查找子串
        System.out.println(str1.indexOf("abcd"));

    }
    public static void main5(String[] args) {
        String str1 = "hello";
        for (int i = 0; i < str1.length(); i++){
            //将变量i作为charAt()方法的参数，被charAt()方法的index参数接收
            System.out.println(str1.charAt(i));

        }
    }
    public static void main3(String[] args) {
        String str1 =  new String("Hello");
        String str2 =  new String("hello");
        System.out.println(str1.compareToIgnoreCase(str2));
    }
    public static void main4(String[] args) {
        String str1 =  new String("HEllo");
        String str2 =  new String("hello");
        //System.out.println(str1 == str2);
        System.out.println(str1.equalsIgnoreCase(str2));
        //System.out.println(str1.compareTo(str2));
    }
    public static void main2(String[] args) {
        String str1 = "hello";
        System.out.println(str1.length());
        int[] array = {1,2,3,4};
        System.out.println(array.length);
        String str2 = "";
        System.out.println(str2.length());
        System.out.println(str2.isEmpty());
        String str3 = null;
    }
    public static void main1(String[] args) {
        String str1 = "hello";
        System.out.println(str1);
        String str2 = new String("hello");
        System.out.println(str2);
        //字符数组
        char[] values = {'a','v','c','d'};
        //这里new String对象，是调用构造方法，将字符数组转化成为字符串。
        String str3 = new String(values);
        System.out.println(str3);
    }
}
